<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> 
<!doctype html>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>lagou manage</title>
  <meta name="description" content="拉勾数据">
  <meta name="keywords" content="二手房 房产经济 房企 开发商 拉勾数据 IFS">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <link rel="icon" type="image/png" href="assets/i/favicon.png">
  <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
  <meta name="apple-mobile-web-app-title" content="eosms for IFS" />
  <link rel="stylesheet" href="assets/css/amazeui.min.css"/>
  <link rel="stylesheet" href="assets/css/admin.css">
  <link rel="stylesheet" href="assets/css/awesomplete.css">
</head>
<body>
<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
  以获得更好的体验！</p>
<![endif]-->

<jsp:include page="/manage_header.do" flush="true"/>

<div class="am-cf admin-main">
  <!-- sidebar start -->
  <jsp:include page="/manage_tree.do" flush="true"/>
  <!-- sidebar end -->

<!-- content start -->
<div class="admin-content">

  <div class="am-cf am-padding">
    <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">二手房</strong> / <small>sale</small></div>
  </div>
<form id="sale_form" class="am-form" action="add_sale.do" method="post" data-am-validator>
<input type="hidden" name="id" id="id" value="0">
<input type="hidden" name="status" value="1">
  <div class="am-tabs am-margin" data-am-tabs>
    <ul class="am-tabs-nav am-nav am-nav-tabs">
      <li><a href="#tab1">概要</a></li>
    </ul>
    <div class="am-tabs-bd">
      <div class="am-tab-panel am-fade" id="tab1">
          <div class="am-g am-margin-top">
            <div class="am-u-sm-2 am-u-md-2 am-text-right">
              	楼盘名称
            </div>
            <div class="am-u-sm-4 am-u-md-4">
            	<input id="building_name" name="building_name" type="text" class="am-input-sm" required>
            </div>
			<div class="am-u-sm-6 am-u-md-6 am-text-right">
            </div>
          </div>
          
          <div class="am-g am-margin-top">
            <div class="am-u-sm-2 am-u-md-2 am-text-right">
             	用途
            </div>
            <div class="am-u-sm-4 am-u-md-4">
              <select id="home_type" name="home_type" class="am-input-sm">
              		<option value="">请选择</option>
              </select>
            </div>
            <div class="am-u-sm-6 am-u-md-6 am-text-right">
            </div>
          </div>
          
          <div class="am-g am-margin-top">
            <div class="am-u-sm-2 am-u-md-2 am-text-right">
             	 建筑类型
            </div>
            <div class="am-u-sm-4 am-u-md-4">
              <select id="build_type" name="build_type" class="am-input-sm">
              	<option value="">请选择</option>
              </select>
            </div>
            <div class="am-u-sm-6 am-u-md-6 am-text-right">
            </div>
          </div>
          
          <div class="am-g am-margin-top">
            <div class="am-u-sm-2 am-u-md-2 am-text-right">
             	 装修状况
            </div>
            <div class="am-u-sm-4 am-u-md-4">
              <select id="fitment" name="fitment" class="am-input-sm">
            	<option value="">请选择</option>
              </select>
            </div>
            <div class="am-u-sm-6 am-u-md-6 am-text-right">
            </div>
          </div>
          
          <div class="am-g am-margin-top">
            <div class="am-u-sm-2 am-u-md-2 am-text-right admin-form-text">
              	建筑年代
            </div>
            <div class="am-u-sm-4 am-u-md-4">
              <input id="build_year" name="build_year" type="text" class="am-input-sm">
            </div>
            <div class="am-u-sm-6 am-u-md-6 am-text-right">
            </div>
          </div>
          
          <div class="am-g am-margin-top">
            <div class="am-u-sm-4 am-u-md-2 am-text-right">
              	朝向
            </div>
            <div class="am-u-sm-8 am-u-md-4">
              <select id="toward" name="toward" class="am-input-sm">
            		<option value="">请选择</option>
              	</select>
            </div>
            <div class="am-u-sm-6 am-u-md-6 am-text-right"></div>
          </div>
          
          <div class="am-g am-margin-top">
            <div class="am-u-sm-2 am-u-md-2 am-text-right">
              	核验编号
            </div>
            <div class="am-u-sm-4 am-u-md-4">
				<input id="check_num" name="check_num" type="text" class="am-input-sm">
            </div>
            <div class="am-u-sm-6 am-u-md-6 am-text-right"></div>
          </div>
          
          <div class="am-g am-margin-top">
            <div class="am-u-sm-2 am-u-md-2 am-text-right">
              	建筑面积
            </div>
            <div class="am-u-sm-4 am-u-md-4">
            	<input id="build_year" name="build_space" type="text" class="am-input-sm">
            </div>
            <div class="am-u-sm-6 am-u-md-6 am-text-right"></div>
          </div>
          
          <div class="am-g am-margin-top">
            <div class="am-u-sm-2 am-u-md-2 am-text-right">
             	 售价
            </div>
            <div class="am-u-sm-4 am-u-md-4 am-input-group">
              <input type="text" class="am-form-field" id="total_price" name="total_price" value="${project.greening_rate}">
              <span class="am-input-group-label">万元/套</span>
            </div>
            <div class="am-u-sm-6 am-u-md-6 am-text-right"></div>
          </div>
          
          <div class="am-g am-margin-top">
            <div class="am-u-sm-2 am-u-md-2 am-text-right">
              	底价
            </div>
            <div class="am-u-sm-4 am-u-md-4 am-input-group">
              <input type="text" class="am-form-field" name="floor_price" id="floor_price" value="${project.property_fee}">
              <span class="am-input-group-label">万元/套</span>
            </div>
            <div class="am-u-sm-6 am-u-md-6 am-text-right"></div>
          </div>
          
          <div class="am-g am-margin-top">
            <div class="am-u-sm-2 am-u-md-2 am-text-right">
             	 户型
            </div>
            <div class="am-u-sm-2 am-u-md-2 am-input-group">
              <input type="text" class="am-form-field" id="bedroom_num" name="bedroom_num" value="${project.property_offices}">
              <span class="am-input-group-label">室</span>
            </div>
            <div class="am-u-sm-2 am-u-md-2 am-input-group">
              <input type="text" class="am-form-field" id="livingroom_num" name="livingroom_num" value="${project.property_offices}">
              <span class="am-input-group-label">厅</span>
            </div>
            <div class="am-u-sm-2 am-u-md-2 am-input-group">
              <input type="text" class="am-form-field" id="toilet_num" name="toilet_num" value="${project.property_offices}">
              <span class="am-input-group-label">卫</span>
            </div>
            <div class="am-u-sm-4 am-u-md-4"></div>
          </div>
          
          <div class="am-g am-margin-top">
            <div class="am-u-sm-2 am-u-md-2 am-text-right">
              	所在楼层
            </div>
            <div class="am-u-sm-2 am-u-md-2">
              <input type="text" class="am-input-sm" id="floor_num" name="floor_num" placeholder="几层" value="${project.presell_licence}">
            </div>
            <div class="am-u-sm-2 am-u-md-2">
              <input type="text" class="am-input-sm" id="totle_floor" name="totle_floor" placeholder="共几层" value="${project.presell_licence}">
            </div>
			<div class="am-u-sm-6 am-u-md-6"></div>
          </div>
          <div class="am-g am-margin-top">
            <div class="am-u-sm-2 am-u-md-2 am-text-right">
              	栋&nbsp;&nbsp;&nbsp;&nbsp;座
            </div>
            <div class="am-u-sm-2 am-u-md-2 am-input-group">
              <input type="text" class="am-form-field" id="building_num" name="building_num" value="${project.property_offices}">
              <span class="am-input-group-label">栋</span>
            </div>
            <div class="am-u-sm-2 am-u-md-2 am-input-group">
              <input type="text" class="am-form-field" id="unit_num" name="unit_num" value="${project.property_offices}">
              <span class="am-input-group-label">单元</span>
            </div>
            <div class="am-u-sm-2 am-u-md-2 am-input-group">
              <input type="text" class="am-form-field" id="apartment_num" name="apartment_num" value="${project.property_offices}">
              <span class="am-input-group-label">号</span>
            </div>
            <div class="am-u-sm-4 am-u-md-4"></div>
          </div>
      </div>
    </div>
  </div>
</form>
  <div class="am-margin">
    <button id="save_button" type="button" class="am-btn am-btn-primary am-btn-xs">提交保存</button>
    <button type="button" class="am-btn am-btn-primary am-btn-xs" onclick="do_back()">放弃保存</button>
  </div>
</div>
<!-- content end -->

</div>

<a href="#" class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu" data-am-offcanvas="{target: '#admin-offcanvas'}"></a>

<footer>
  <hr>
  <p class="am-padding-left">© 2014 AllMobilize, Inc. Licensed under MIT license.</p>
</footer>

<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="assets/js/jquery.min.js"></script>
<!--<![endif]-->
<script src="assets/js/amazeui.min.js"></script>
<script src="assets/js/app.js"></script>
<script src="assets/js/awesomplete.js"></script>
<script type="text/javascript">
var input = document.getElementById("building_name");
new Awesomplete(input, {
	list: ["Ada", "Java", "JavaScript", "Brainfuck", "LOLCODE", "Node.js", "Ruby on Rails","广阳"],
	minChars: 1
});

$(function() {
	var paraJson = $.parseJSON('${paraJson}');
	$.each(paraJson,function(i,param){
		var select;
		if(param.type=="01"){
			select = $("#home_type");
			select.append("<option value="+param.value+">"+param.name+"</option>");
			return;
		}
		if(param.type=="02"){
			select = $("#fitment");
			select.append("<option value="+param.value+">"+param.name+"</option>");
			return;
		}
		if(param.type=="03"){
			select = $("#toward");
			select.append("<option value="+param.value+">"+param.name+"</option>");
			return;
		}
	});
	
	//用途下拉框选择后级联获得建筑类型下拉框内容
	$("#home_type").change(function(){
		var select = $("#build_type");
		select.empty();
		select.append("<option value=''>请选择</option>");
		$.each(paraJson,function(i,param){
			if(param.type == $("#home_type").val()){
				select.append("<option value="+param.value+">"+param.name+"</option>");
			}
		});
		$("#build_type").focus();
	});
	
	//建筑类型下拉框选择后装修状况下拉框获得焦点
	$("#build_type").change(function(){
		$("#fitment").focus();
	});
	
	//装修状况下拉框选择后建筑年代获得焦点
	$("#fitment").change(function(){
		$("#build_year").focus();
	});
	
	//建筑年代市区焦点后朝向获得焦点
	$("#build_year").blur(function(){
		$("#toward").focus();
	});
	
	
	
	//保存按钮点击事件
	$("#save_button").click(function() {
		var saveData={"id":$("#id").val(),"building_name":$("#building_name").val(),"home_type":$("#home_type").val(),"build_type":$("#build_type").val(),"fitment_type":$("#fitment_type").val(),
				"build_year":$("#build_year").val(),"toward":$("#toward").val(),"check_num":$("#check_num").val(),"total_price":parseFloat($("#total_price").val()),"floor_price":parseFloat($("#floor_price").val()),
				"build_space":$("#build_space").val(),"bedroom_num":parseInt($("#bedroom_num").val()),"livingroom_num":parseInt($("#livingroom_num").val()),"toilet_num":parseInt($("#toilet_num").val()),
				"floor_num":$("#floor_num").val(),"totle_floor":parseInt($("#totle_floor").val()),"building_num":$("#building_num").val(),"unit_num":$("#unit_num").val(),
				"apartment_num":$("#apartment_num").val(),"status":1};
		$.ajax({
			contentType:"application/json",
		    type : "POST",
		    url : "<%=request.getContextPath()%>/add_sale.do",
		    data : JSON.stringify(saveData),
		    dataType: "json",
		    success : function(data) {
		        if(data.flag=="1"){
		        	$("#id").val(data.id);
		            alert("保存成功！");
		        }
		        else{
		            alert("保存失败！");
		        }
		    },
		    error :function(){
		        alert("网络连接出错！");
		    }
		});
	});
});
</script>
</body>
</html>
